package com.ejoysoft.wlanyz.business;

import com.ejoysoft.auth.MD5;
import com.ejoysoft.common.*;
import com.ejoysoft.common.exception.UserUnitIdException;
import com.ejoysoft.wlanyz.system.Unit;
import com.ejoysoft.wlanyz.system.User;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import java.util.ArrayList;
import java.util.Vector;
import java.util.HashMap;
import java.util.Date;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;

public class Paper {
	private Globa globa;
    private DbConnect db;
    

    public Paper() {
    }

    public Paper(Globa globa) {
        this.globa = globa;
        db = globa.db;
    }

    public Paper(Globa globa, boolean b) {
        this.globa = globa;
        db = globa.db;
        if (b) globa.setDynamicProperty(this);
    }
 
    String strTableName = "WLAN_RESC_HOTPOT";

  
    
    
  //返回热点id对应的热点名
    public String getAcId(String where) {
        try {
            String strSql = "select * from  " + strTableName + "  ".concat(where);
            ResultSet rs = db.executeQuery(strSql);
            if (rs != null && rs.next())
            {
            	String ACID = rs.getString("strid");
            	rs.close();
                return ACID;
            }
            else
                return null;
        } catch (Exception ee) {
            return null;
        }
    }
    
    //调出所有热点的城市名称
    public ArrayList<Object[]> getAllclassoneByName( String where )
    {
    	DbConnect dbConnect = new DbConnect();
    	ArrayList<Object[]>  beans = new ArrayList<Object[]>();
    	String sql = "select distinct(STRCLASSONEHP) from "+strTableName+" ";
    	if(where!=null && where.length()>0)
    		sql = sql +" "+where;
    	ResultSet re = dbConnect.executeQuery(sql);
    	try {
			if(re != null && re.next())
			{
				do{
					Object[] theBean = new Object[2];
					String classoneac = re.getString("STRCLASSONEHP");
					theBean[0] = classoneac;
					theBean[1] = this.getAllstrclasstwoByName(classoneac);
					beans.add(theBean);
				}while(re.next());
			}
			re.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		dbConnect.closeCon();
    	return beans;
    }
    //调出城市所有二级热点名称
    public ArrayList<String> getAllstrclasstwoByName( String classoneac)
    {   DbConnect dbConnect = new DbConnect();
    	ArrayList<String>  beans = new ArrayList<String>();
    	String sql = "select distinct(STRHOTPOTNAME) from "+strTableName+" ";
    	String where = " where STRHOTPOTNAME='"+classoneac+"'";
    	sql = sql+where;
    	System.out.println("sql"+sql);
    	ResultSet re = dbConnect.executeQuery(sql);
    	try { 
			if(re != null && re.next())
			{   //String strcountry = re.getString("");
				do{
					String classtwoac = re.getString("STRHOTPOTNAME");
					beans.add(classtwoac);
				}while(re.next());
			}
			re.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		dbConnect.closeCon();
    	return beans;
    }
    //调出二级热点名称
    public ArrayList<String> getAllclassTwoAcByName(String classoneac)
    {
    	DbConnect dbConnect = new DbConnect();
    	ArrayList<String>  beans = new ArrayList<String>();
    	String sql = "select distinct(STRHOTPOTNAME) from "+strTableName+" ";
    	String where = " where STRHOTPOTNAME = '"+classoneac+"' ";
    	sql = sql+where;
    	ResultSet re = dbConnect.executeQuery(sql);
    	try { 
			if(re != null && re.next())
			{   //String strcountry = re.getString("");
				do{
					String classtwoac = re.getString("STRHOTPOTNAME");
					beans.add(classtwoac);
				}while(re.next());
			}
			re.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		dbConnect.closeCon();
    	return beans;
    }
    

    private String strId;
    private String strAcName;// 二级热点在热点关联表（二级热点表）对应的id
    private String classtwoac;
    private String strCadName;		
    private String strCadPic;			
    private String intFloor;
    private	String strCity;
    private String strCountry;
    private String clssOneAc;
    private String clssTwoAc;
    private String strCreator;//			创建人
    private String dCreatDate;//		创建时间



    public String getStrId() {
        return strId;
    }

    public void setStrId(String strId) {
        this.strId = strId;
    }

    public String getAcName() {
        return strAcName;
    }

    public void setAcName(String strAcName) {
        this.strAcName = strAcName;
    }
    public String getclasstwoac() {
        return classtwoac;
    }

    public void setclasstwoac(String classtwoac) {
        this.classtwoac = classtwoac;
    }
    
    public String getCadName() {
		return strCadName;
	}
    
    public void setCadName(String strCadName){
    	 this.strCadName = strCadName;
    }
    
    public String getCadPic() {
		return strCadPic;
	}
    
    public void setCadPic(String strCadPic){
    	this.strCadPic = strCadPic;
    }
    public String getFloor() {
		return intFloor;
	}
    
    public void setFloor(String intFloor){
    	this.intFloor = intFloor;
    }
   
    public String getStrCity() {
		return strCity;
	}
    
    public void setStrCity(String strCity){
    	this.strCity = strCity;
    }
    public String getStrCountry() {
		return strCountry;
	}
    
    public void setStrCountry(String strCountry){
    	this.strCountry = strCountry;
    }
    public String getClssOneAc() {
		return clssOneAc;
	}
    
    public void setClassOneAc(String clssOneAc){
    	this.clssOneAc = clssOneAc;
    }
    public String getClssTwoAc() {
		return clssTwoAc;
	}
    
    public void setClssTwoAc(String clssTwoAc){
    	this.clssTwoAc = clssTwoAc;
    }
    
 
    public String getStrCreator() {
        return strCreator;
    }

    public void setStrCreator(String strCreator) {
        this.strCreator = strCreator;
    }

    public String getdCreatDate() {
        return dCreatDate;
    }

    public void setdCreatDate(String dCreatDate) {
        this.dCreatDate = dCreatDate;
    }
}
